package com.ljy.mapper;

import com.ljy.dto.LeasePageDTO;
import com.ljy.entity.Goods;
import com.ljy.entity.Lease;
import com.ljy.entity.RollImage;
import com.ljy.vo.LeaseVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface LeaseMapper {
    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into lease(name, tag,category_id,category_name, image, express, scope, pickup," +
            " description, service, video, create_time, update_time,  pay_method, invoice,stock)" +
            "values (#{name},#{tag},#{categoryId},#{categoryName},#{image},#{express},#{scope},#{pickup},#{description},#{service},#{video}," +
            "#{createTime},#{updateTime},#{payMethod},#{invoice},#{stock})")
    void insert(Lease lease);

    List<LeaseVO>selectPage(LeasePageDTO dto);


    @Select("select id, category_id, category_name, name, tag, image, " +
            "express, scope, pickup, description, service, video, create_time, " +
            "update_time, status, pay_method, invoice,stock  from lease where id=#{id}" )
    Lease selectById(Integer id);

    void batchDelete(List<Integer> ids);



    @Update("update lease set name=#{name},category_id=#{categoryId},category_name=#{categoryName},tag=#{tag},image=#{image},express=#{express}," +
            "scope=#{scope},pickup=#{pickup},description=#{description},service=#{service},video=#{video}," +
            "update_time=#{updateTime},pay_method=#{payMethod},invoice=#{invoice},stock=#{stock} " +
            "where id=#{id}")
    void updateLease(Lease lease);

    @Update("update lease set status=#{status} where id=#{id}")
    void changeStatus(Short status, Integer id);

    @Delete("delete from roll_image")
    void rollImageDelete();
    void rollImageSubmit(List<RollImage> rollImages);

    @Select("select id, name, image from roll_image")
    List<RollImage> rollImageSelect();
}
